import request from "@/utils/request";
import { AddFood, Update_Food } from "@/types/foods"



enum FOODAPI {
    ADDFOOD = '/foods',
    FOODLIST = '/foods/food/list',
    RECOMMENT = "/foods/recomment/list",
    SEARCH = "/foods/searchlist",
    CREATE = '/foods/userfood',
    ADDVIEW = "/foods/addview"
}
export const ADD_Food = (data: AddFood) => request({
    method: "POST",
    url: FOODAPI.ADDFOOD,
    data,
})
export const Get_One = (id: string) => request({
    method: "GET",
    url: FOODAPI.ADDFOOD + `/${id}`,
})
export const PutFood = (id: string, data: Update_Food) => request({
    method: "PUT",
    url: FOODAPI.ADDFOOD + `/${id}`,
    data
})
export const Getlist = (skip = 0) => request({
    method: "GET",
    url: FOODAPI.FOODLIST + `/${skip}`
})
export const GetComment = () => request({
    method: "GET",
    url: FOODAPI.RECOMMENT
})
export const GetSwiper = () => request({
    method: "GET",
    url: FOODAPI.RECOMMENT + "/swiper"
})
export const searchfood = (keyword: string) => request({
    method: "POST",
    url: FOODAPI.SEARCH,
    data: {
        keyword: keyword
    }
})
//获取用户创作品
export const userfood = (id: string, skip = 0) => request({
    method: "GET",
    url: FOODAPI.CREATE + `/${id}/${skip}`
})


export const addview = (id: string) => request({
    method: "PUT",
    url: FOODAPI.ADDVIEW,
    data: {
        id
    }
})